app.controller('goodsDetailEvaluateCtrl',['$scope','$stateParams','goodsDetailEvaluateService','toaster',function($scope,$stateParams,goodsDetailEvaluateService,toaster){
    $scope.id=$stateParams.id;
    $scope.goods;
    $scope.page=0;
    $scope.length=5;

    //查询商品id
    $scope.findById=function(){
        goodsDetailEvaluateService.findById($scope).then(function(result){
            switch (result.status){
                case 200:
                    $scope.goods=result.data;
                    break;
                default :
                    toaster.pop('error', "操作失败", "发生未知错误！请联系管理员");
                    break
            }
        });
    }
    $scope.findById();

    //查询全部评价
    $scope.list=new Array();
    $scope.findAll=function(){
        goodsDetailEvaluateService.findAll($scope).then(function(result){
            $scope.list.push.apply($scope.list,result.list);
            if(result.list.length==0){
                $scope.moreState=true;
            }

        });
    }

    $scope.findAll();

    //更多评价
    $scope.evaluateMore=function(){
        $scope.page++;
        $scope.findAll();
    }

    $scope.moreState=false;

    //查询评价数据总和
    $scope.findEvaluateCount=function(){
        goodsDetailEvaluateService.findEvaluateCount($scope).then(function(result){
            switch (result.status){
                case 200:
                    $scope.evaluateCount=result.data;
                    break;
                default :
                    toaster.pop('error', "操作失败", "发生未知错误！请联系管理员");
                    break
            }
        });
    }
    $scope.findEvaluateCount();

}])